package io.unicorn.modules.water.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.unicorn.common.utils.PageUtils;
import io.unicorn.common.utils.Query;
import io.unicorn.modules.water.service.DataErrAlertFixedService;
import io.unicorn.modules.waterfgs.dao.DataErrAlertFixedFgsDao;
import io.unicorn.modules.waterfgs.entity.DataErrAlertFixedFgsEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("DataErrAlertFixedService")
public class DataErrAlertFixedServiceImpl extends ServiceImpl<DataErrAlertFixedFgsDao, DataErrAlertFixedFgsEntity> implements DataErrAlertFixedService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //查找部门ID
        //String unitId = params.get("unitId").toString();

        String deptId = (String)params.get("dept");
        String key   = (String)params.get("key");
        String value = (String)params.get("value");

        IPage<DataErrAlertFixedFgsEntity> page = this.page(
                new Query<DataErrAlertFixedFgsEntity>().getPage(params),
                new QueryWrapper<DataErrAlertFixedFgsEntity>()
                        //.eq("unit_id",unitId)
                        .like(StringUtils.isNotEmpty(deptId),"dept_id", deptId)
                        .like(StringUtils.isNotBlank(value) && StringUtils.isNotBlank(key), key, value)
        );

        return new PageUtils(page);
    }

}
